<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class Country extends Model
{

    use SoftDelete;


    // 表名
    protected $name = 'country';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [

    ];


    const VN = 1;
    const TH = 2;
    const MY = 3;

    public function getCountryList($keyValue = 0): array
    {
        if ($keyValue == self::VN) {
            return [self::VN => __('VN')];
        }
        if ($keyValue == self::TH) {
            return [self::VN => __('TH')];
        }
        if ($keyValue == self::MY) {
            return [self::VN => __('MY')];
        }

        return [
            self::VN => '越南',
            self::TH => '泰国',
            self::MY => '马来',
        ];
    }

    public function getCountryListStringIndex(): array
    {
        return [
            strval(self::VN) => '越南',
            strval(self::TH) => '泰国',
            strval(self::MY) => '马来',
        ];
    }

    public function getCountryListIdName(): array
    {
        return [
            ["id" => strval(self::VN), "name" => '越南'],
            ["id" => strval(self::TH), "name" => '泰国'],
            ["id" => strval(self::MY), "name" => '马来']
        ];
    }

    public function getNameAttr($value)
    {
        $status = $this->getCountryList();
        return $status[$value];
    }


}
